package com.dwxt.community.admin.service;

import com.alibaba.fastjson.JSONObject;
import com.dwxt.common.base.BaseResult;
import com.dwxt.community.entity.vo.UserActionRecordVo;
import com.dwxt.community.service.InformationService;
import com.dwxt.community.service.UserActionRecordService;
import com.dwxt.community.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;

@Service
public class OperationManagerService {

    @Autowired
    private UserActionRecordService userActionRecordService;
    @Autowired
    private UserService userService;
    @Autowired
    private InformationService informationService;

    public LinkedHashMap operationTargerData(String date) {
        LinkedHashMap<String, Integer> map = new LinkedHashMap<String,Integer>();

        map.put("注册人数",0);
        map.put("app分享数",0);

        map.put("资讯发布量",0);
        map.put("资讯点击量",0);
        map.put("资讯点赞数",0);
        map.put("资讯分享数",0);

        map.put("直播点击量",0);
        //map.put("直播点赞数",0);
        map.put("直播分享数",0);

        //map.put("商城营业额",0);
        //map.put("商城订单数",0);

        map.put("商品分享数",0);
        map.put("商品点击量",0);


        Integer informationCount = informationService.countByCreateTime(date);
        List<UserActionRecordVo> userActionRecordVo = userActionRecordService.countByCreateTime(date);
        userActionRecordVo.forEach(uarv -> map.put(uarv.getModelInfo() + uarv.getActionName(), uarv.getCount()));
        Integer userRegsterCount = userService.countUserByCreateTime(date);
        userActionRecordService.countStrByCreateTime(date).forEach(str ->map.put(str.getModelInfo()+"点赞数",str.getCount()));
        map.put("注册人数", userRegsterCount);
        map.put("资讯发布量", informationCount);
        return map;
    }
}
